﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EbayMaster
{
    public partial class FrmItemSourcing : Form
    {
        public FrmItemSourcing()
        {
            InitializeComponent();
        }

        private void FrmItemSourcing_Load(object sender, EventArgs e)
        {
            SetupDataGridViewColumns();

            this.dataGridViewAllItems.AutoGenerateColumns = false;

            DataTable dt = ItemDAL.GetAllItems();
            this.dataGridViewAllItems.DataSource = dt;
        }

        private void SetupDataGridViewColumns()
        {
            // ItemSKU
            DataGridViewTextBoxColumn itemSKUCol = new DataGridViewTextBoxColumn();
            itemSKUCol.DataPropertyName = "ItemSKU";
            itemSKUCol.HeaderText = @"商品SKU";
            itemSKUCol.ValueType = typeof(string);
            itemSKUCol.Width = 100;
            itemSKUCol.Frozen = true;
            this.dataGridViewAllItems.Columns.Add(itemSKUCol);

            // ItemName
            DataGridViewTextBoxColumn itemNameCol = new DataGridViewTextBoxColumn();
            itemNameCol.DataPropertyName = "ItemName";
            itemNameCol.HeaderText = @"商品名称";
            itemNameCol.ValueType = typeof(string);
            itemNameCol.Width = 180;
            itemNameCol.Frozen = true;
            this.dataGridViewAllItems.Columns.Add(itemNameCol);

            // ItemStockNum
            DataGridViewTextBoxColumn itemStockNumCol = new DataGridViewTextBoxColumn();
            itemStockNumCol.DataPropertyName = "ItemStockNum";
            itemStockNumCol.HeaderText = @"当前库存";
            itemStockNumCol.ValueType = typeof(int);
            itemStockNumCol.Width = 60;
            itemStockNumCol.Frozen = true;
            this.dataGridViewAllItems.Columns.Add(itemStockNumCol);

            // ItemStockShresholdNum
            DataGridViewTextBoxColumn itemStockShresholdNumCol = new DataGridViewTextBoxColumn();
            itemStockShresholdNumCol.DataPropertyName = "ItemStockShresholdNum";
            itemStockShresholdNumCol.HeaderText = @"库存报警值";
            itemStockShresholdNumCol.ValueType = typeof(int);
            itemStockShresholdNumCol.Width = 90;
            itemStockShresholdNumCol.Frozen = true;
            this.dataGridViewAllItems.Columns.Add(itemStockShresholdNumCol);

            // ItemCost
            DataGridViewTextBoxColumn itemPriceCol = new DataGridViewTextBoxColumn();
            itemPriceCol.DataPropertyName = "ItemCost";
            itemPriceCol.HeaderText = @"价格￥";
            itemPriceCol.ValueType = typeof(double);
            itemPriceCol.Width = 70;
            itemPriceCol.Frozen = true;
            this.dataGridViewAllItems.Columns.Add(itemPriceCol);

            DataGridViewTextBoxColumn itemSourcingCountCol = new DataGridViewTextBoxColumn();
            itemSourcingCountCol.ReadOnly = false;
            itemSourcingCountCol.HeaderText = @"进货数量";
            itemSourcingCountCol.ValueType = typeof(double);
            itemSourcingCountCol.Width = 70;
            this.dataGridViewAllItems.Columns.Add(itemSourcingCountCol);

            this.dataGridViewAllItems.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.dataGridViewAllItems.MultiSelect = true;
            //this.dataGridViewAllItems.RowPrePaint += new DataGridViewRowPrePaintEventHandler(dgv_RowPrePaint);

        }
    }
}
